﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyBanHang_N3A
{
    public partial class FormManHinhChinh : Form
    {
        public FormManHinhChinh()
        {
            InitializeComponent();
        }
        public string MaNV;

        private bool CheckExistForm(string name)
        {
            foreach (Form frm in this.MdiChildren)
                if (frm.Name == name)
                    return true;
            return false;
        }
        private void ActiveChildForm(string name)
        {
            foreach (Form frm in this.MdiChildren)
                if (frm.Name == name)
                {
                    frm.Activate();
                    break;
                }
        }
        private void FormManHinhChinh_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
            //DialogResult res= MessageBox.Show("Bạn muốn thoát khỏi chương trình?", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            //if (DialogResult.Yes == res)
            //    Application.Exit();
            //else
            //    this.ShowDialog();
        }
        
        private void mnPhucHoi_Click(object sender, EventArgs e)
        {

            if (!CheckExistForm("FormPhucHoi"))
            {
                FormPhucHoi frm = new FormPhucHoi();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormPhucHoi");
        }
        private void mnThoat_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
        private void mnBanHang_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormBanHang"))
            {
                FormBanHang frm = new FormBanHang();
                frm.MaNV = MaNV;
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormBanHang");
        }
        private void mnDatHang_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormDatHang"))
            {
                FormDatHang frm = new FormDatHang();
                frm.MaNV = MaNV;
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormDatHang");
        }
        private void mnNhapHang_Click(object sender, EventArgs e)
        {

            if (!CheckExistForm("FormNhapHang"))
            {
                FormNhapHang frm = new FormNhapHang();
                frm.MaNV = MaNV;
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormNhapHang");
        }
        private void mnTraCuuKhachHang_Click(object sender, EventArgs e)
        {

            if (!CheckExistForm("FormTraCuuKhachHang"))
            {
                FormTraCuuKhachHang frm = new FormTraCuuKhachHang();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormTraCuuKhachHang");
        }
        private void mnBaoCao_Click(object sender, EventArgs e)
        {

            if (!CheckExistForm("FormBaoCao"))
            {
                FormBaoCao frm = new FormBaoCao();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormBaoCao");
        }
        private void mnThongTinKhachHang_Click(object sender, EventArgs e)
        {

            if (!CheckExistForm("FormThongTinKhachHang"))
            {
                FormThongTinKhachHang frm = new FormThongTinKhachHang();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormThongTinKhachHang");
        }
        private void mnThongTinNhanVien_Click(object sender, EventArgs e)
        {

            if (!CheckExistForm("FormThongTinNhanVien"))
            {
                FormThongTinNhanVien frm = new FormThongTinNhanVien();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormThongTinNhanVien");
        }
        private void mnSanPham_Click(object sender, EventArgs e)
        {


            if (!CheckExistForm("FormSanPham"))
            {
                FormSanPham frm = new FormSanPham();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormSanPham");
        }

        private void mnTheoDoiNhapHang_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormTheoDoiNhapHang"))
            {
                FormTheoDoiNhapHang frm = new FormTheoDoiNhapHang();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormTheoDoiNhapHang");
        }


        private void mnSaoLuu_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormSaoLuuDB"))
            {
                FormSaoLuuDB frm = new FormSaoLuuDB();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FromSaoLuuDB");
        }



        private void mnT_Click__(object sender, EventArgs e)
        {
            
        }

        private void mnTheoDoiDatHang_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormTheoDoiDatHang"))
            {
                FormTheoDoiDatHang frm = new FormTheoDoiDatHang();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormTheoDoiDatHang");
        }

        private void mnTheoDoiBanHang_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormTheoDoiBanHang"))
            {
                FormTheoiDoiBanHang frm = new FormTheoiDoiBanHang();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormTheoDoiBanHang");
        }

        private void mnTheoDoiNhapTon_Click(object sender, EventArgs e)
        {
            if (!CheckExistForm("FormTheoDoiXNT"))
            {
                FormTheoDoiXNT frm = new FormTheoDoiXNT();
                frm.MdiParent = this;
                frm.Show();
            }
            else
                ActiveChildForm("FormTheoDoiXNT");
        }

        private void mnGioiThieu_Click(object sender, EventArgs e)
        {
            //if (!CheckExistForm("FormGioiThieu"))
            //{
            //    FormGioiThieu frm = new FormGioiThieu();
            //    //frm.MdiParent = this;
            //    frm.ShowDialog();
            //}
            //else
            //    ActiveChildForm("FormGioiThieu");
            FormGioiThieu frm = new FormGioiThieu();
            //frm.MdiParent = this;
            frm.ShowDialog();
        }

        private void FormManHinhChinh_Load(object sender, EventArgs e)
        {
            if (MaNV != "quanly")
            {
                mnThongTinNhanVien.Visible = false;
            }
        }


        



    }
}
